layui.use(['element', 'form'], function () {
    var element = layui.element
    var form = layui.form
    var $ = layui.$

    // 国旗图标配置文件
    var langIcon = {
        "0": "./image/China.png",
        '1': "./image/usa.jpg",
    }

    $('#lang .layui-anim.layui-anim-upbit').find('dd').each(function (index, item) {
        var img = new Image()
        img.src = langIcon[index]
        img.style.marginRight="10px"
        img.style.width="29px"
        img.style.height="18px"
        $(item).prepend(img)
    })


    // 下滑菜单
    $(".l-glide-menu").on('click', function (e) {
        if(!$('.l-glide-icon').hasClass('l-active'))  {
            $('.l-glide-icon').addClass('l-active')

            // 显示菜单
            $('.l-glide-content').removeClass('l-active')
            //遍历菜单选项
            $('.l-glide-content .l-glide-item').each(function (index, item) {
                Velocity(item, {
                    top:  index*40+"px"
                },{
                    duration: 1000
                })
            })
        } else {
            $('.l-glide-icon').removeClass('l-active')

            //遍历菜单选项
            var glideMenu =  $('.l-glide-content .l-glide-item')
            glideMenu.each(function (index, item) {
                Velocity(item, {
                    top:  0
                },{
                    duration: 1000
                })


                if(index === glideMenu.length -1 )  {
                    setTimeout( function () {
                        $('.l-glide-content').addClass('l-active')
                    }, 1000)
                }
            })

        }
    })
})